import 'dart:convert' show json;

class ZhiYaoModel {

  int iRspCode;
  List<ZhiYaoData> data;

  ZhiYaoModel.fromParams({this.iRspCode, this.data});

  factory ZhiYaoModel(jsonStr) => jsonStr == null ? null : jsonStr is String ? new ZhiYaoModel.fromJson(json.decode(jsonStr)) : new ZhiYaoModel.fromJson(jsonStr);

  ZhiYaoModel.fromJson(jsonRes) {
    iRspCode = jsonRes['iRspCode'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : new ZhiYaoData.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"iRspCode": $iRspCode,"data": $data}';
  }
}

class ZhiYaoData {

  int iArticleId;
  String dCreateDate;
  String pics;
  String sAuthor;
  String sContent;
  String sFromWhere;
  String sThumbPicture;
  String sTitle;
  String url;

  ZhiYaoData.fromParams({this.iArticleId, this.dCreateDate, this.pics, this.sAuthor, this.sContent, this.sFromWhere, this.sThumbPicture, this.sTitle, this.url});

  ZhiYaoData.fromJson(jsonRes) {
    iArticleId = jsonRes['iArticleId'];
    dCreateDate = jsonRes['dCreateDate'];
    pics = jsonRes['pics'];
    sAuthor = jsonRes['sAuthor'];
    sContent = jsonRes['sContent'];
    sFromWhere = jsonRes['sFromWhere'];
    sThumbPicture = jsonRes['sThumbPicture'];
    sTitle = jsonRes['sTitle'];
    url = jsonRes['url'];
  }

  Map toMap(){
    return {
      "pics":pics,
      "sAuthor":sAuthor,
      "sContent":sContent,
      "sFromWhere":sFromWhere,
      "sThumbPicture":sThumbPicture,
      "sTitle":sTitle,
      "url":url,
    };
  }

  @override
  String toString() {
    return '{"iArticleId": $iArticleId,"dCreateDate": ${dCreateDate != null?'${json.encode(dCreateDate)}':'null'},"pics": ${pics != null?'${json.encode(pics)}':'null'},"sAuthor": ${sAuthor != null?'${json.encode(sAuthor)}':'null'},"sContent": ${sContent != null?'${json.encode(sContent)}':'null'},"sFromWhere": ${sFromWhere != null?'${json.encode(sFromWhere)}':'null'},"sThumbPicture": ${sThumbPicture != null?'${json.encode(sThumbPicture)}':'null'},"sTitle": ${sTitle != null?'${json.encode(sTitle)}':'null'},"url": ${url != null?'${json.encode(url)}':'null'}}';
  }
}

